/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* 头部样式 */
header {
    text-align: center;
    padding: 30px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

header h1 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 2.5rem;
    font-weight: 700;
}

header h1 i {
    color: #667eea;
    margin-right: 15px;
}

.subtitle {
    color: #7f8c8d;
    font-size: 1.2rem;
    font-weight: 400;
}

/* 主内容区域 */
.main-content {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 600px;
    position: relative;
}

/* 聊天区域 - 主要内容 */
.chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* 辅助信息面板 */
.assistant-panel {
    width: 400px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    overflow: hidden;
}

.assistant-panel.collapsed {
    width: 60px;
}

.assistant-panel.collapsed .panel-content {
    display: none;
}

.assistant-panel.collapsed .panel-header h3 {
    display: none;
}

.assistant-panel.collapsed .toggle-panel i {
    transform: rotate(0deg);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 15px 15px 0 0;
}

.panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.toggle-panel {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-panel:hover {
    background: rgba(255, 255, 255, 0.3);
}

.toggle-panel i {
    transition: transform 0.3s ease;
    transform: rotate(180deg);
}

.panel-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* 聊天容器 */
.chat-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
    margin-bottom: 20px;
}

.chat-header h2 {
    color: #2c3e50;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header i {
    color: #667eea;
    font-size: 1.5rem;
}

/* 状态指示器 */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.status-indicator.ready {
    background: #e8f5e8;
    color: #27ae60;
}

.status-indicator.processing {
    background: #fff3cd;
    color: #f39c12;
}

.status-indicator.error {
    background: #f8d7da;
    color: #e74c3c;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 聊天消息 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
    max-height: 400px;
}

.message {
    max-width: 85%;
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.user-message {
    align-self: flex-end;
}

.user-message .message-content {
    flex-direction: row-reverse;
}

.user-message .message-text {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 15px 20px;
    border-radius: 20px;
    border-bottom-right-radius: 5px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.ai-message .message-text {
    background: #f8f9fa;
    color: #2c3e50;
    padding: 15px 20px;
    border-radius: 20px;
    border-bottom-left-radius: 5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.message-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.user-message .message-icon {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.ai-message .message-icon {
    background: #e9ecef;
    color: #667eea;
}

/* 聊天输入 */
.chat-input {
    display: flex;
    gap: 15px;
    align-items: center;
}

.chat-input input {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.chat-input input:focus {
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-input button {
    padding: 15px 25px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.chat-input button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.chat-input button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 响应面板 */
.response-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    overflow: hidden;
}

/* 标签页 */
.panel-tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.tab-button {
    flex: 1;
    padding: 15px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: #6c757d;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-button:hover {
    background: #e9ecef;
    color: #495057;
}

.tab-button.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: white;
}

/* 标签页内容 */
.tab-content {
    display: none;
    height: 500px;
    overflow-y: auto;
}

.tab-content.active {
    display: block;
}

/* 流式数据标签页 */
.stream-header, .nodes-header, .data-header, .chart-header, .sql-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

.stream-header h3, .nodes-header h3, .data-header h3, .chart-header h3, .sql-header h3 {
    color: #2c3e50;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.stream-header i, .nodes-header i, .data-header i, .chart-header i, .sql-header i {
    color: #667eea;
    font-size: 1.2rem;
}

.data-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.data-count {
    background: #667eea;
    color: white;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.9rem;
    font-weight: 500;
}

.copy-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.copy-btn:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

/* 流式数据内容 */
.stream-content {
    padding: 20px;
}

.stream-item {
    margin-bottom: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.stream-time {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 8px;
}

.stream-data {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    background: white;
    padding: 10px;
    border-radius: 5px;
    white-space: pre-wrap;
    overflow-x: auto;
}

.stream-data.has-query-data {
    background: #e8f5e8;
    border: 2px solid #28a745;
}

.query-data-indicator {
    background: #28a745;
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    margin-top: 5px;
    display: inline-block;
}

/* 节点流程样式 */
.nodes-content {
    padding: 20px;
}

.nodes-flow {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.node-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #667eea;
    transition: all 0.3s ease;
    position: relative;
}

.node-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

.node-item.completed {
    border-left-color: #28a745;
    background: #e8f5e8;
}

.node-item.processing {
    border-left-color: #ffc107;
    background: #fff3cd;
    animation: pulse 2s infinite;
}

.node-item.error {
    border-left-color: #dc3545;
    background: #f8d7da;
}

.node-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-right: 15px;
    flex-shrink: 0;
}

.node-icon.start {
    background: #28a745;
    color: white;
}

.node-icon.end {
    background: #6c757d;
    color: white;
}

.node-icon.process {
    background: #667eea;
    color: white;
}

.node-icon.completed {
    background: #28a745;
    color: white;
}

.node-icon.processing {
    background: #ffc107;
    color: #212529;
}

.node-icon.error {
    background: #dc3545;
    color: white;
}

.node-content {
    flex: 1;
}

.node-name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 5px;
    font-size: 1.1rem;
}

.node-description {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.node-details {
    font-size: 0.8rem;
    color: #868e96;
    background: white;
    padding: 8px 12px;
    border-radius: 5px;
    margin-top: 8px;
    border: 1px solid #dee2e6;
}

.node-time {
    font-size: 0.8rem;
    color: #6c757d;
    margin-left: 10px;
    white-space: nowrap;
}

.node-arrow {
    position: absolute;
    left: 50%;
    bottom: -15px;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #dee2e6;
}

.node-item:last-child .node-arrow {
    display: none;
}

.nodes-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nodes-count {
    background: #667eea;
    color: white;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.9rem;
    font-weight: 500;
}

.nodes-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6c757d;
    text-align: center;
}

.nodes-placeholder i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* 数据表格 */
.data-content {
    padding: 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.data-table th {
    background: #667eea;
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: 600;
}

.data-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #e9ecef;
}

.data-table tr:hover {
    background: #f8f9fa;
}

/* 图表容器 */
.chart-content {
    padding: 20px;
}

.chart-container {
    width: 100%;
    height: 500px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    background: white;
    position: relative;
    overflow: hidden;
}

/* 图表加载状态 */
.chart-container.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

.chart-container.loading::before {
    content: "正在生成图表...";
    color: #6c757d;
    font-size: 14px;
}

/* 图表响应式调整 */
@media (max-width: 768px) {
    .chart-container {
        height: 400px;
    }
}

@media (max-width: 480px) {
    .chart-container {
        height: 300px;
    }
}

.chart-error {
    padding: 20px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 10px;
    color: #721c24;
}

.chart-error h4 {
    margin-bottom: 10px;
    color: #721c24;
}

.chart-error pre {
    background: #fff;
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px;
    overflow-x: auto;
    font-size: 0.8rem;
}

.chart-raw-data {
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #dee2e6;
}

.chart-raw-data h4 {
    margin-bottom: 10px;
    color: #495057;
}

.chart-raw-data pre {
    background: #fff;
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* SQL内容 */
.sql-content {
    padding: 20px;
}

.sql-code {
    background: #2d3748;
    color: #e2e8f0;
    padding: 20px;
    border-radius: 10px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

.sql-code pre {
    margin: 0;
    white-space: pre-wrap;
}

/* 占位符 */
.stream-placeholder, .data-placeholder, .chart-placeholder, .sql-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6c757d;
    text-align: center;
}

.stream-placeholder i, .data-placeholder i, .chart-placeholder i, .sql-placeholder i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

/* 信息面板 */
.info-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    text-align: center;
}

.info-label {
    font-size: 0.9rem;
    color: #6c757d;
    font-weight: 500;
}

.info-value {
    font-size: 1.1rem;
    color: #2c3e50;
    font-weight: 600;
}

.info-value.success {
    color: #27ae60;
}

.info-value.error {
    color: #e74c3c;
}

/* 页脚 */
footer {
    text-align: center;
    padding: 20px;
    color: white;
    font-size: 0.9rem;
    opacity: 0.8;
}

/* 通知 */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 10px;
    color: white;
    font-weight: 500;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.notification.success {
    background: #27ae60;
}

.notification.error {
    background: #e74c3c;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .response-panel {
        order: -1;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .chat-input {
        flex-direction: column;
        gap: 10px;
    }
    
    .chat-input button {
        width: 100%;
        justify-content: center;
    }
    
    .panel-tabs {
        flex-wrap: wrap;
    }
    
    .tab-button {
        flex: 1 1 50%;
        font-size: 0.9rem;
        padding: 12px 15px;
    }
    
    .info-panel {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .chart-container {
        height: 300px;
    }
}

@media (max-width: 480px) {
    .info-panel {
        grid-template-columns: 1fr;
    }
    
    .tab-button {
        flex: 1 1 100%;
    }
}

/* AI回复中的特殊内容样式 */
.message-text .data-preview {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    font-family: inherit;
}

.message-text .data-preview h4 {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.message-text .data-preview h4 i {
    color: #667eea;
}

.message-text .summary-info {
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border: 1px solid #bbdefb;
    border-radius: 8px;
    padding: 12px;
    margin: 10px 0;
    font-size: 0.85rem;
}

.message-text .summary-info .info-item {
    display: flex;
    justify-content: space-between;
    margin: 5px 0;
}

.message-text .summary-info .info-label {
    font-weight: 600;
    color: #1976d2;
}

.message-text .summary-info .info-value {
    color: #424242;
}

.message-text .data-table-preview {
    margin-top: 10px;
    overflow-x: auto;
}

.message-text .data-table-preview table {
    width: 100%;
    font-size: 0.8rem;
    border-collapse: collapse;
    background: white;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.message-text .data-table-preview th {
    background: #f8f9fa;
    padding: 8px;
    border: 1px solid #dee2e6;
    font-weight: 600;
    color: #495057;
}

.message-text .data-table-preview td {
    padding: 8px;
    border: 1px solid #dee2e6;
    color: #6c757d;
}

.message-text .chart-preview {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    text-align: center;
}

.message-text .chart-preview h4 {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.message-text .chart-preview h4 i {
    color: #28a745;
}

.message-text .sql-preview {
    background: #2d3748;
    color: #e2e8f0;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    overflow-x: auto;
}

.message-text .sql-preview h4 {
    margin: 0 0 10px 0;
    color: #90cdf4;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.message-text .sql-preview h4 i {
    color: #f6ad55;
}

.message-text .sql-preview pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-all;
}

.message-text .response-text {
    margin-bottom: 15px;
    line-height: 1.6;
}

/* 打字动画样式 */
.typing-animation {
    position: relative;
}

.typing-dots {
    display: inline-block;
    margin-left: 5px;
}

.typing-dots span {
    display: inline-block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: #667eea;
    margin: 0 1px;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0s;
}

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 思考状态样式 */
.message-text.thinking {
    color: #6c757d;
    font-style: italic;
}

/* 流式输出样式 */
.message-text.streaming {
    border-right: 2px solid #667eea;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% {
        border-color: #667eea;
    }
    51%, 100% {
        border-color: transparent;
    }
}
